
<?php

/*
 * Read the items from file and put them into a json string
 */
$items = array();
$file = fopen("gifts.csv", "r");
while (!feof($file)) {
    $data = explode(';', fgets($file));
    if (count($data) > 0) {
        $items[] = (object) array(
                    'index' => $data[0],
                    'type' => $data[1],
                    'prize' => $data[2],
                    'text' => trim($data[3]),
        );
    }
}
fclose($file);

echo json_encode($items);
?>

